$(function () {
    var oHtml = document.documentElement;
    function getSize() {
        var screenWidth = oHtml.offsetWidth;
        if (screenWidth >= 640) {
            oHtml.style.fontSize = '40px';
        } else if (screenWidth <= 320) {
            oHtml.style.fontSize = '23.7037px';
        } else {
            // 动态去计算这个屏幕下的font-size值
            oHtml.style.fontSize = screenWidth / (640 / 40) + 'px';
        }
    }
    getSize();
    window.addEventListener('resize', getSize);
    //checkbox
    $('.price-model .checkbox').on('click', function () {
        if ($(this).hasClass('active')) {
            $(this).removeClass('active');
        } else {
            $(this).addClass('active');
        }
    });
    //footNav
    $('.footer > .button').on('click', function () {
        var $this = $(this),
            $target = $this.data('target');
        window.location = $target;
    });
    $(".footer > .button").each(function () {
        var $this = $(this),
            $active = $this.data("value");
        if (request("active") == $active) {
            $this.children().addClass('active');
            $this.siblings().children().removeClass('active');
        }
    });
    function request(keyValue) {
        var search = location.search.slice(1);
        var arr = search.split("&");
        for (var i = 0; i < arr.length; i++) {
            var ar = arr[i].split("=");
            if (ar[0] == keyValue) {
                if (unescape(ar[1]) == 'undefined') {
                    return "";
                } else {
                    return unescape(ar[1]);
                }
            }
        }
        return "";
    }
});
